/**
 * 
 */
package dbAccess;

import java.sql.*;

import exceptions.*;

import model.Imprimerie;

/**
 * @author Anthares & Hennek
 *
 */
public class ImprimerieDBAccess {
	public Imprimerie getImprimerie(int imprimerieID) throws PasIdentificationException, DatabaseErrorException{
		Connection conn = DBConnexionSingleton.getInstance();
		PreparedStatement stat;
		Imprimerie imp = null;
		String query = "select * from imprimerie where fournisseur_id = ?;";
		try {
			stat = conn.prepareStatement(query);
				stat.setInt(1, imprimerieID);
			ResultSet data = stat.executeQuery();
			while(data.next()){
				imp = new Imprimerie(data.getInt("fournisseur_id"), data.getDouble("prix"), data.getString("contrat"));
			}
			stat.close();
		} catch (SQLException e) {
			throw new DatabaseErrorException(e);
		}
		return imp;
	}
}
